//
//  DiscountViewController.m
//  HondaPro_2
//
//  Created by ht on 13-9-24.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "DiscountViewController.h"

@interface DiscountViewController ()

@end

@implementation DiscountViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self.view setFrame:CGRectMake(0, 0, 500, 530)];
    
    self.customerListTableView = [[UITableView alloc]initWithFrame:CGRectMake(20, 100, self.view.frame.size.width-20-20, self.view.frame.size.height-100-70)];
    [self.customerListTableView setDelegate:self];
    [self.customerListTableView setDataSource:self];
    [self.view addSubview:self.customerListTableView];
    
//    self.cellListArray = [NSMutableArray arrayWithArray:[self.getUserListDit objectForKey:@"userList"]];
    
    [self shaBiZhaoShaoFei];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_DISCOUNT_LISTArr count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    static NSString *indetfire = @"cell";
    DiscountCell *cell = [tableView dequeueReusableCellWithIdentifier:indetfire];
    if(nil == cell)
    {
        cell = [[DiscountCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
//    cell.userNumber.text = [[self.cellListArray objectAtIndex:row]objectForKey:@"userNumber"];
//    cell.LoginName.text = [[self.cellListArray objectAtIndex:row]objectForKey:@"loginName"];
//    cell.customerName.text = [[self.cellListArray objectAtIndex:row]objectForKey:@"customerName"];
    cell.zhekoumingcheng.text = [[_DISCOUNT_LISTArr objectAtIndex:row]objectForKey:@"DISCOUNT_MODE_NAME"];
    cell.lingjian.text = [[[_DISCOUNT_LISTArr objectAtIndex:row]objectForKey:@"REPAIR_PART_DISCOUNT"] stringValue];
    cell.gongshi.text = [[[_DISCOUNT_LISTArr objectAtIndex:row]objectForKey:@"LABOUR_AMOUNT_DISCOUNT"] stringValue];
    cell.qita.text = [[[_DISCOUNT_LISTArr objectAtIndex:row]objectForKey:@"ADD_ITEM_DISCOUNT"] stringValue];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row%2 == 1)
    {
        cell.backgroundColor = [UIColor whiteColor];
    }
    else
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:226.00/255 green:226.00/255 blue:226.00/255 alpha:1];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    zhaoShaoFeiWoCaoNiMaLeGeBi
    NSNotification *notification = [NSNotification notificationWithName:@"zhaoShaoFeiWoCaoNiMaLeGeBi" object:[_DISCOUNT_LISTArr objectAtIndex:indexPath.row]];
    [[NSNotificationCenter defaultCenter]postNotification:notification];
}

-(void)shaBiZhaoShaoFei
{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(45, 55, 650, 40)];
//    label.text = @"      工号                          登录名                         员工名      ";
    label.text = @"折扣类型          零件折扣          工时折扣         其他折扣";
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor grayColor];
    label.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.view addSubview:label];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
